home *** CD-ROM | disk | FTP | other *** search
- Path: HOPPER.ACM.ORG!news
- From: varnk@e62.diebold.com (Ken Varn)
- Newsgroups: comp.lang.c++
- Subject: C++ beginner quesion on data member access.
- Date: 10 Apr 1996 12:57:10 GMT
- Organization: Diebold
- Message-ID: <4kgb76$r3s@HOPPER.ACM.ORG>
- NNTP-Posting-Host: 199.218.232.47
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-Newsreader: WinVN 0.99.7
-
-
- I have been struggling with the proper way to declare and access data
- members in my classes. I was once told that a class should not allow any
- data members to be public and that they should only be accessed via member
- functions. Why? I know the reasons for declaring private data, but what do
- I gain if all I am doing is providing a member function to get the private
- data or set the private data. i.e. why call a getData() function that
- basically just returns the private data member as opposed to just declaring
- the pviate data member as public.
-
-
-